Skip to content

crypto: the asynchronous family over the synchronous backends, and the heavy machinery on webcpp::hash's model - #14

Merged
pinhopro merged 16 commits into
mainfrom
crypto/async
Nov 22, 2026
Merged

pinhopro merged 16 commits into
mainfrom
crypto/async

Conversation

@pinhopro

Copy link
Copy Markdown
Contributor

Increment 4, part A of the foundation: <webcpp/crypto/async.hpp>, the asynchronous family over the synchronous backends, and the heavy operations' machinery rebuilt on webcpp::hash's model.

The family (each takes first the executor its completion is posted to, holds detail::timing_guard first, runs the synchronous call at initiation and completes through a post, never inline; an error completes with the empty object, which refuses every member with invalid_state):

  • AES-GCM: async_make<Gcm>, async_seal -> void(error_code, tag), async_open -> void(error_code)
  • Ed25519: async_generate, async_make<Keypair>, async_sign -> void(error_code, std::array<uint8_t, 64>), async_verify -> void(error_code)
  • X25519: async_agree -> void(error_code, secret<32>)
  • P-256 (BearSSL): async_generate, async_make from the raw scalar, async_sign and async_verify over the message (hashed with SHA-256, as WebCrypto's ECDSA does), async_agree (the raw x coordinate)
  • default_async_backend_t<Family> is the synchronous default on every target; detail::asynchronous_backend_v and detail::async_engine are the seam part B's browser backend fills.
  • A family WebCrypto lacks stops at compile time with a message naming the synchronous call.

The heavy machinery (detail/heavy.hpp): detail::run_on_work ports hash's heavy_state, heavy_job and heavy_initiation, carrying a value: guards checked on the caller's thread, the work on the work executor, completion on the handler's associated executor, cancellation before the start (every type) and during it (terminal, partial), values that wipe themselves, every state in the handler's associated allocator. No public heavy operation exists yet.

Also: doc/async.adoc and two examples (async_seal, async_sign), the capability table's async rows per family, the generator's per-overload briefs in llms.txt, coverage of every async function in the timing coverage tests, and fixes the Linux lint and GCC 15 release builds asked for.

Verified locally: native clang and GCC 15, wasip2, wasip3 and Emscripten in debug and release (the heavy test natively and on Emscripten with -pthread), generate.py --check, the doc build, the macOS and Linux lints, MSVC 14.3 and 14.5 under Wine (one emulator-only failure, async_p256_no_exceptions, the known no-/EH Boost.JSON artifact). Measurements: none. The CI runs at the end of the owner's queue.

R added 16 commits November 21, 2026 21:21
… cancellation before and during the work and values that wipe themselves
…d work executor tested, and a heavy operation's value must move without throwing
…y target

Also the review's minors of the AES-GCM commit: the Jamfile's wording of when a call runs, the async_make documentation now true for key pairs, and the async_engine seam's documented shape.
…rage counter is generic, and the review's minors of 4.A3 and 4.A4 are closed
…tions, with use cases, and the sign example reports a missing public key
…ior, a const AES-GCM object gets the constness error, and crypto.hpp names the header it leaves out
…use, and the changelog's first line fits its word limit
…e on GCC 15 release, with the counting operators never inlined and each awaited result named before it is bound
…ts landing on main

# Conflicts:
#	test/Jamfile
#	test/convenience_header_test.cpp
…s and use cases, and the P-256 chapter and the seam name the message the async functions hash
…er-case helpers, and its const and trailing-comma lint findings are fixed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant